/**
 * 
 */
package com.questiono;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.facebook.widget.ProfilePictureView;
import com.sameer.questiono.R;

/**
 * @author sameer
 *
 */
public class Score extends Activity {

	private Sound sound;
	public static final String PREFS_NAME = "Questiono";  
	private ProfilePictureView profilePictureView;
    private TextView userNameView,score,tot,cor;
	private int ans,total,correct, points,best;
	
	
	 @Override
	    protected void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.scorecard);
	        
	        //Setting FONT
	     // Font path
	        String fontName= "fonts/Disko.ttf";
	        String fontPath = "fonts/PWApril.ttf";
	 
	        // text view label
	        TextView txtGhost = (TextView) findViewById(R.id.question);
	 
	        // Loading Font Face
	        Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
	        Typeface tfname = Typeface.createFromAsset(getAssets(), fontName);
	 
	        // Applying font
	        txtGhost.setTypeface(tf);
	        
	        // End of Font settings
	        
	        MediaPlayer mPlayer = new MediaPlayer();
	        mPlayer = MediaPlayer.create(this, R.raw.loop); 
	        //mPlayer.start();
	        
	        profilePictureView = (ProfilePictureView) findViewById(R.id.selection_profile_pic);
		    profilePictureView.setCropped(true);
		    userNameView=(TextView) findViewById(R.id.selection_user_name);
		    score=(TextView) findViewById(R.id.best);
		    tot=(TextView) findViewById(R.id.question);
		    cor=(TextView) findViewById(R.id.correct);
	        
		    score.setTypeface(tf);
		    tot.setTypeface(tf);
		    cor.setTypeface(tf);
		    userNameView.setTypeface(tfname);
		    
		    
	        SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
		    String name = settings.getString("name", null);
		    String photoId = settings.getString("photoId", null);
		    String email = settings.getString("email", null);
		    total= (int) settings.getLong("total", 0);
		    correct= (int) settings.getLong("correct", 0);
		    best= (int) settings.getLong("best", 0);
		    profilePictureView.setProfileId(photoId);
		    userNameView.setText(name);
		    
		    
		  //  Log.i("SCORE",name);
		    tot.setText(  "TOTAL QUESTIONS \t"+total+"");
		    cor.setText(  "CORRECT ANSWERS \t"+correct+"");
		    score.setText("PERSONAL BEST   \t"+best+"");
	      
	          
	    }
	 
	 public void onFinish(View view)
		{
		    
	
		/*	
			Intent nextScreen = new Intent(getApplicationContext(), HomeScreen.class);
		
			startActivity(nextScreen);*/
		 
			
			Intent nextScreen = new Intent(getApplicationContext(), Graphs.class);
		
			startActivity(nextScreen);
			
		}
	 
	 
	// Adding Override for the Hardware Back key
			@Override
			public boolean onKeyDown(int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_BACK) {
					moveTaskToBack(true);
					return true;
				}
				return super.onKeyDown(keyCode, event);
			}
	 
}
